<template>
<!--歌单页-->
  <div class="songListShow" v-if="infoSongs">
    <div class="singerInfo">
      <div class="centent">
        <div class="head">
          <img :src="infoSongs.creator.avatarUrl" alt />
        </div>
        <div class="text">
          <h1>创建者：{{infoSongs.creator.nickname}}</h1>
          <div class="expand">
            <p>简介：{{infoSongs.description}}</p>
          </div>
          <div class="toolbar">
            <span class="green">播放所有歌曲</span>
            <span>分享+{{infoSongs.shareCount}}</span>
          </div>
        </div>
      </div>
    </div>
    <ul v-if="infoSongs" class="song">
      <li>
        <remark :remarkInfo="remark" />
      </li>
      <li
        v-for="(val,index) in infoSongs.tracks"
        :key="index"
        :class="index%2==1?'evenBackground':''"
      >
        <ul class="showInfo">
          <li class="flex2" @click="skipGrabble('playSong',val.id)">
            {{val.name}}
            <img src="~@/assets/img/play.png" width="25px" alt />
          </li>
          <li @click="skipGrabble('GrabbleType100',val.ar[0].id)">{{val.ar[0].name}}</li>
          <li @click="skipGrabble('albumPage',val.al.id)">{{val.al.name}}</li>
          <li class="cen">{{new Date(val.publishTime).toLocaleString()}}</li>
        </ul>
      </li>
    </ul>
  </div>
</template>

<script>
import remark from "components/searchComponents/remark";
import require from "requests/getSong";
export default {
  name: "songListShow",
  data() {
    return {
      remark: {
        grid1: "歌曲",
        grid2: "歌手",
        grid3: "专辑",
        grid4: "发布时间"
      },
      infoSongs: null
    };
  },
  components: {
    remark
  },
  methods: {
    getSongs(id) {
      require.songsDynamic(id).then(res => {
        this.infoSongs = res.data.playlist;
        console.log(this.infoSongs);
      });
    },
    skipGrabble(path, val) {
      if (path != "playSong") {
        this.$router.push({
          name: path,
          query: {
            keyWord: val
          }
        });
        return;
      }
      const newUrl = this.$router.resolve({
        name: path,
        query: {
          keyWord: val
        }
      });
      window.open(newUrl.href, "_blank");
    }
  },
  mounted() {
    this.getSongs(this.$route.query.keyWord);
  }
};
</script>

<style scoped lang='less'>
.songListShow {
  .song {
    li {
      .showInfo {
        display: flex;
        padding: 0;
        height: 50px;
        li {
          flex: 1;
          line-height: 50px;
          word-break: keep-all;
          white-space: nowrap;
          overflow: hidden;
          text-overflow: ellipsis;
          font-family: "Courier New", Courier, monospace;
        }
        li.flex2 {
          flex: 2;
          img {
            vertical-align: middle;
            float: right;
            display: none;
            margin: 10px 30px;
          }
        }
        li.flex2:hover > img {
          display: inline-block;
        }
        li:hover {
          color: #31c27c;
          cursor: pointer;
        }
        li.cen {
          text-align: center;
        }
      }
    }
  }
  .singerInfo {
    background-color: #f5f5f5;
    height: 300px;
    display: flex;
    justify-content: center;
    align-items: center;
    .centent {
      .head {
        width: 200px;
        display: inline-block;
        margin-right: 50px;
        img {
          width: 200px;
          height: 200px;
          border-radius: 50%;
        }
      }
      .text {
        display: inline-block;
        width: 800px;
        font-size: 14px;
        line-height: 24px;
        h1 {
          font-size: 38px;
          font-weight: 400;
        }
        .expand {
          position: relative;
          p {
            margin: 0;
            display: inline-block;
            width: 90%;
            white-space: nowrap;
            text-overflow: ellipsis;
            overflow: hidden;
          }
        }
      }
      .toolbar {
          margin-top:30px ;
        cursor: pointer;
        span {
          border: 1px solid #c9c9c9;
          margin: 0 10px;
          padding: 10px;
          border-radius: 5px;
        }
        span.green {
          border: 1px solid #31c27c;
          background-color: #31c27c;
          color: #fff;
        }
      }
    }
  }
}
.evenBackground {
  background-color: rgba(0, 0, 0, 0.01);
}
</style>